package com.baichang.taoshunda.controller.mobile;

import com.baichang.framework.controller.BaseMobileController;
import com.baichang.framework.controller.IService;
import com.baichang.framework.excelption.ServiceException;
import com.baichang.taoshunda.controller.ControllerConstants;
import com.baichang.taoshunda.service.PensionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @param
 * @author: wsl
 * @Date: 2018/11/30 14：40
 * @Description:
 */

@Controller
@RequestMapping(ControllerConstants.PENSION)
public class PensionController extends BaseMobileController {

    @Autowired
    private PensionService pensionService;

    /**
     * 功能描述:
     * 查询我的养老补贴金
     *
     * @param:
     * @return:
     * @auther: wsl
     * @date: 2018/11/30 14:44
     */
    @RequestMapping("/findPensionList")
    public void findPensionList(HttpServletRequest request, HttpServletResponse response) {
        initEncode(request, response, new IService() {
            @Override
            public Object init(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, String json) throws ServiceException {
                Integer userId = getInt(json, "userId", 0);
                Integer nowPage = getInt(json, "nowPage", 1);
                Integer pageSize = getInt(json, "pageSize", 20);
                return pensionService.findPensionList(userId, nowPage, pageSize);
            }
        });
    }

    /**
     * 功能描述:
     * 查询我的养老信息
     *
     * @param:
     * @return:
     * @auther: wsl
     * @date: 2018/11/30 14:44
     */
    @RequestMapping("/getUserPensionByUserId")
    public void getUserPensionByUserId(HttpServletRequest request, HttpServletResponse response) {
        initEncode(request, response, new IService() {
            @Override
            public Object init(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, String json) throws ServiceException {
                Integer userId = getInt(json, "userId", 0);
                return pensionService.getUserPensionByUserId(userId);
            }
        });
    }

}
